export const storage = {
  get(key: string) {
    const value = localStorage.getItem(key)
    try {
      return JSON.parse(value || "")
    } catch (error) {
      return value
    }
  },
  set(key: string, value: string) {
    if (typeof value !== "string") {
      value = JSON.stringify(value)
    }
    localStorage.setItem(key, value)
  },
  remove(key: string) {
    localStorage.removeItem(key)
  },
  clear() {
    localStorage.clear()
  }
}
